require('module-alias/register')
require('@/redis')
require('@/websocket')
const chalk = require('chalk')
const config = require('config')
const express = require('express')
const bodyParser = require('body-parser')
const session = require('express-session')
const cookieParser = require('cookie-parser')
const routerInstall = require('@/routes')
const requestIp = require('request-ip')
const swaggerInstall = require('@/utils/swagger.unit')
const interceptorVisit = require('@/middleware/interceptor.middleware')
// const BadWords = require('@/utils/badwords.util')
// const badWords = BadWords.instance
const app = express()
swaggerInstall(app)
app.use(cookieParser())
app.use(session(config.get('session')))
app.use(requestIp.mw())
app.use(interceptorVisit)
app.use(bodyParser.json({ limit: '10mb' }))
app.use(bodyParser.urlencoded({ limit: '10mb', extended: true }))
routerInstall(app)
app.listen(config.get('server.port'), () => {
  console.log('app listening on server ' + chalk.green(`http://${config.get('server.host')}:${config.get('server.port')}`))
})
